

$VMName = "myvm"

 $VM = @{
     Name = $VMName
     MemoryStartupBytes =  1024 * 1024 * 512 
     Generation = 2
     NewVHDPath = "G:\Virtual Machines\$VMName\$VMName.vhdx"
     NewVHDSizeBytes = 1024 * 1024 * 1024 * 50
     BootDevice = "VHD"
     Path = "G:\Virtual Machines\$VMName"
     SwitchName = (Get-VMSwitch | ? name -eq "Default Switch").name
 }

 New-VM @VM
